package test.com.adapter;

import java.util.List;

import test.com.R;
import test.com.domain.All_wines;
import test.com.domain.FavsuitSelect;
import test.com.domain.WineWLife;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class FavsuitSelectListAdapter extends BaseAdapter{

	private List<FavsuitSelect> list;
	private Context mContext;
	private ViewHolder holder;
	
	public FavsuitSelectListAdapter(Context mContext, List<FavsuitSelect> list) {
		this.mContext = mContext;
		this.list = list;
	}
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView==null || convertView.getTag()==null){
			convertView=LayoutInflater.from(mContext).inflate(R.layout.favsuitselectlist,null);
			holder = new ViewHolder();
			holder.favsuitselname=(TextView) convertView.findViewById(R.id.favsuitselname);
			holder.favsuitselImage=(ImageView) convertView.findViewById(R.id.favsuitselImage);
			convertView.setTag(holder);
			}else{
				holder=(ViewHolder) convertView.getTag();
			}
		if(list.get(position).isSelect()){
			holder.favsuitselImage.setBackgroundResource(R.drawable.bg_search_on);
		}else{
			holder.favsuitselImage.setBackgroundResource(R.drawable.bg_search_off);
		}
		holder.favsuitselname.setText(list.get(position).getName());
		return convertView;
	}

	class ViewHolder{
		public TextView favsuitselname;
		private ImageView favsuitselImage;
		
	}
}
